define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'csmonline/tableonline/index'
                }
            });
            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                columns: [
                    [
                        {field: 'id', title: __('Id'), operate: false},    
                        {field: 'isloginuser', title: __('用户类型'), operate: false
                            , formatter: function (value, row, index) {
                                if(row.user_id=='N'){
                                    return '游客';
                                }else{
                                    return '登录用户';
                                }
                            }
                        },
                        {field: 'userid', title: __('用户标记')},
                        {field: 'user_id', title: __('用户ID')},
                        {field: 'username', title: __('昵称')},
                        {field: 'email', title: __('Email')},
                        {field: 'calccountry', title: __('国家')},
                        {field: 'calcprovince', title: __('省份') },
                        //{field: 'calismobile', title: __('访问设备'), formatter: Table.api.formatter.status, searchList: {'Y': __('手机'), 'N': __('PC')}},
                        {field: 'calismobile', title: __('访问设备'), searchList: {"Y":__('手机'),"N":__('PC电脑')}, formatter: Table.api.formatter.status},

                        {field: 'maxcreatetime', title: __('访问时间'), formatter: Table.api.formatter.datetime, type: 'datetime', data: 'data-date-format="YYYY-MM-DD"'},
                        {field: 'visitpages', title: __('访问页面数') },
                        {field: 'durationseconds', title: __('访问时间(秒)') },
                        {field: 'operate', title: __('Operate'), table: table, buttons: [
                                {name: 'detail', text: '详情', title: '详情', icon: 'fa fa-list', classname: 'btn btn-xs btn-primary btn-dialog', url: 'csmonline/tableonlinetrace/index'}
                            ], events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ],
                //普通搜索
                commonSearch: false,
                titleForm: '', //为空则不显示标题，不定义默认显示：普通搜索
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
           
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});